package com.qust.enDecrpytion.looPool;

import lombok.Data;
import lombok.ToString;

import java.util.Stack;

public interface LooPool<T> {
    @Data
    @ToString(exclude = "stack")
    class Node<T> {
        private Stack<Node<T>> stack;
        private T node;
        private Status status;
        public Node(T node, Stack<Node<T>> stack){
            this.node = node;
            this.status = Status.idle;
            this.stack = stack;
        }

        public Node(T node){
            this(node,null);
        }

        public void close() {
            if (stack != null){
                this.status = Status.idle;
                stack.push(this);
            }
        }
    }

    enum Status{
        idle,busy
    }

    void addNode(T node);
    void remove(Node<T> node);
    Node<T> getIdleNode();

}
